package ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.mainframeSub;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;

import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.model.RFC;

public class ShowAndCancelDialog extends JDialog {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private JButton cancelButton;

	public ShowAndCancelDialog(JFrame parent, RFC rfc) {
		super(parent, true);
		this.setResizable(false);
		this.setSize(600, 600);
		this.setLocation(400, 200);
		this.setLayout(new BorderLayout());

		this.cancelButton = new JButton("Schliessen");
		this.cancelButton.addActionListener(new CancelButtonListener());

		this.add(new RFCDisplay(rfc), BorderLayout.CENTER);
		this.add(new ButtonPanel(), BorderLayout.SOUTH);

		this.setVisible(true);
	}

	private class ButtonPanel extends JPanel {

		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

		private ButtonPanel() {
			setLayout(new FlowLayout());
			this.add(cancelButton);

		}
	}

	private class CancelButtonListener implements ActionListener {

		@Override
		public void actionPerformed(ActionEvent e) {

			ShowAndCancelDialog.this.dispose();
		}

	}

}
